To add static C1TreeView items to the C1TreeView control in the code behind file, edit the code in your application so it appears like the following:
Visual Basic |
Copy Code
|
---|---|
Imports C1.Xaml Class MainPage Public Sub New() InitializeComponent() InitializeTreeView() End Sub Private Sub InitializeTreeView() ' Remove items that were added at design time Tree.Items.Clear() Dim booklist As New C1TreeViewItem() booklist.Header = "Book List" Tree.Items.Add(booklist) ' Adding child items Dim language As New C1TreeViewItem() language.Header = "Language Books" booklist.Items.Add(language) ' Adding child items Dim security As New C1TreeViewItem() security.Header = "Security Books" booklist.Items.Add(security) ' Adding child items Dim classic As New C1TreeViewItem() classic.Header = "Classic Books" booklist.Items.Add(classic) ' Adding child items Dim subclassic As New C1TreeViewItem() subclassic.Header = "Catch-22" classic.Items.Add(subclassic) Dim subclassic2 As New C1TreeViewItem() subclassic2.Header = "The Great Gatsby" classic.Items.Add(subclassic2) End Sub End Class |
C# |
Copy Code
|
---|---|
using C1.Xaml; public MainPage() { InitializeComponent(); InitializeTreeView(); } void InitializeTreeView() { // Remove items that were added at design time Tree.Items.Clear(); C1TreeViewItem booklist = new C1TreeViewItem(); booklist.Header = "Book List"; Tree.Items.Add(booklist); // Adding child items C1TreeViewItem language = new C1TreeViewItem(); language.Header = "Language Books"; booklist.Items.Add( language ); // Adding child items C1TreeViewItem security = new C1TreeViewItem(); security.Header = "Security Books"; booklist.Items.Add(security); // Adding child items C1TreeViewItem classic = new C1TreeViewItem(); classic.Header = "Classic Books"; booklist.Items.Add(classic); // Adding child items C1TreeViewItem subclassic = new C1TreeViewItem(); subclassic.Header = "Catch-22"; classic.Items.Add(subclassic); C1TreeViewItem subclassic2 = new C1TreeViewItem(); subclassic2.Header = "The Great Gatsby"; classic.Items.Add(subclassic2); } |